<!DOCTYPE html>
<html>

<head>
<meta charset="UTF-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport"
	content="initial-scale=1, maximum-scale=1, user-scalable=no">
<title>首页</title>
<link rel="stylesheet"
	href="http://192.168.6.18/arcgis_js_api/library/3.17/3.17/esri/css/esri.css">
<link rel="stylesheet" type="text/css"
	href="/ylly-forestry-resources-webapp/assets/libs/Esri-dojo-theme-flat-4e1fdb1/CSS/dojo/flat.css" />
<link rel="stylesheet" type="text/css"
	href="/ylly-forestry-resources-webapp/assets/libs/Esri-dojo-theme-flat-4e1fdb1/CSS/dgrid/css/dgrid.css" />
<link rel="stylesheet" type="text/css"
	href="/ylly-forestry-resources-webapp/assets/libs/Esri-dojo-theme-flat-4e1fdb1/CSS/dgrid/css/skins/skin.css" />
<link rel="stylesheet" type="text/css"
	href="/ylly-forestry-resources-webapp/assets/libs/Esri-dojo-theme-flat-4e1fdb1/CSS/dgrid/css/extensions/Pagination.css" />
<link rel="stylesheet" type="text/css"
	href="/ylly-forestry-resources-webapp/assets/libs/Esri-dojo-theme-flat-4e1fdb1/CSS/esri/css/esri_custom.css" />
<style>
html, body, #mainWindow {
	font-family: sans-serif;
	height: 100%;
	width: 100%;
}

html, body {
	margin: 0;
	padding: 0;
}

#header {
	height: 80px;
	overflow: auto;
	padding: 0.5em;
}
</style>
<script>
	var href = window.document.location.href;
	var index = href.lastIndexOf("/js/") + 3;
	var jsPath = href.substring(0, index);
	var dojoConfig = {
		async : true,
		labsPath : "/ylly-forestry-resources-webapp/assets/libs",
		packages : [ {
			name : "widget",
			location : jsPath + "/widget"
		}, {
			name : "project",
			location : jsPath + "/project"
		} ]
	};
</script>
<script
	src="http://192.168.6.18/arcgis_js_api/library/3.17/3.17/init.js"></script>
<script>
	var map, toolbar, symbol, geomTask;

	require(
			[ "esri/map", "esri/layers/ArcGISTiledMapServiceLayer",
					"esri/layers/FeatureLayer",
					"esri/renderers/SimpleRenderer", "esri/InfoTemplate",
					"esri/symbols/SimpleLineSymbol",
					"esri/symbols/SimpleFillSymbol", "esri/Color",
					"esri/graphic", "esri/tasks/FeatureSet", "dojo/parser",
					"dijit/registry", "dojo/dom", "dojo/on",
					"widget/draw/draw", "widget/task/IdentityTask",
					"dojo/_base/array", "dijit/Dialog",
					"dijit/layout/BorderContainer", "dijit/layout/ContentPane",
					"dijit/form/Button", "dijit/WidgetSet", "dojo/domReady!" ],
			function(Map, ArcGISTiledMapServiceLayer, FeatureLayer,
					SimpleRenderer, InfoTemplate, SimpleLineSymbol,
					SimpleFillSymbol, Color, Graphic, FeatureSet, parser,
					registry, dom, on, Draw, IdentityTask, arrayUtils, Dialog) {
						parser.parse();
						map = new Map("map", {
							center : [ 106.5, 34.5 ],
							zoom : 3,
							slider : false,
							logo : false
						});
				var baseLayer = new ArcGISTiledMapServiceLayer("http://192.168.6.18/arcgis/rest/services/ylly/yuyangxiaoban_cache/MapServer");
				map.addLayer(baseLayer);
				var addBn = dom.byId("CIRCLE");
				var addBn1 = dom.byId("RECTANGLE");
				var addBn2 = dom.byId("POINT");
				on(addBn, "click", query1);
				on(addBn1, "click", query1);
				on(addBn2, "click", query1);
				function query1(eve) {
					var draw = new Draw(
							{
								map : map,
								// CIRCLE point RECTANGLE
								type : eve.currentTarget.id,
								callback : function(evt) {
									var query = new IdentityTask(
											{
												layers : "http://192.168.6.18/arcgis/rest/services/ylly/yuyangxiaoban_cache/MapServer",
												layerIds : [ 0 ],
												mapPoint : evt.geometry
											});
									var deferred = query.excute();
									deferred.then(function(res) {
												map.graphics.clear();
												map.infoWindow.hide();
												var features = [];
												var featureSet = new FeatureSet();
												arrayUtils.map(res,function(result) {
																	feature = result.feature;
																	var taxParcelTemplate = new InfoTemplate(
																			"小班属性",
																			"省 : ${SHENG}<br />县 : ${XIAN}<br />乡 : ${XIANG}<br />村 : ${CUN}");
																	feature
																			.setInfoTemplate(taxParcelTemplate);
																	feature
																			.setSymbol(new SimpleFillSymbol())
																	map.graphics
																			.add(feature);
																	features
																			.push(feature);
																});
												featureSet.features = features;
												return featureSet;
											});
								}
							});
					draw.activate();
				}
			});
</script>
</head>

<body class="nihilo">

	<div id="mainWindow" data-dojo-type="dijit/layout/BorderContainer"
		data-dojo-props="design:'headline'">
		<div id="header" data-dojo-type="dijit/layout/ContentPane"
			data-dojo-props="region:'top'">
			<button data-dojo-type="dijit/form/Button" id="CIRCLE" value="Circle">圆</button>
			<button data-dojo-type="dijit/form/Button" id="RECTANGLE">框选</button>
			<button data-dojo-type="dijit/form/Button" id="POINT">点选</button>
		</div>
		<div id="map" data-dojo-type="dijit/layout/ContentPane"
			data-dojo-props="region:'center'"></div>

		<div style="height: 20px; width: 65px; display: none;" id="panel"></div>
	</div>

</body>

</html>